# encoding: UTF-8
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'User'

class Director < User
  attr_accessor :school
  
  def initialize(login, password, name, surname)
    super(login, password, name, surname)
    @school = 1
  end;
  
  def employ_teacher(teacher)
    if school.login_used(teacher.login)
      raise ArgumentError, "Naudotojas su tokiu login jau egzistuoja"
    end
    @school.teachers << teacher
    teacher.school = @school
  end
  
  def add_class(new_class, class_master)
    if school.class_title_used(new_class.title)
      raise ArgumentError, "Klasė tokiu pavadinimu jau ezistuoja"
    end
    @school.classes << new_class
    class_master.mastering_class = new_class
  end

  def admit_student(student)
    if school.login_used(student.login)
      raise ArgumentError, "Naudotojas su tokiu login jau egzistuoja"
    end
    @school.students <<  student
    student.school_class.students << student
    student.school = school
  end
end